home *** CD-ROM | disk | FTP | other *** search
/ Gamers Delight 2 / Gamers Delight 2.iso / Aminet / game / misc / ShuffleRun.lzh / ShuffleRun / Sources.lha / Sources / SR2.c < prev   
C/C++ Source or Header  |  1993-02-13  |  31KB  |  1,428 lines

  1. #include <exec/types.h>
  2. #include <exec/memory.h>
  3. #include <intuition/intuition.h>
  4. #include <graphics/text.h>
  5. #include <libraries/dos.h>
  6. #include <EasySound.h>
  7.  
  8. #define FLOOR 2
  9. #define BONUS 3
  10. #define GREYWALL 1
  11. #define PINKWALL 0
  12. #define PINKWALL2 4
  13. #define CLOSEDDOOR 5
  14. #define OPENEDDOOR 6
  15. #define KEY 7
  16. #define HOLE 8
  17. #define P1BONUS 9
  18. #define P2BONUS 10
  19.  
  20. extern struct TextAttr Font1DEF;
  21. extern struct TextAttr Font2DEF;
  22. extern struct NewScreen PanelScreenDEF;
  23. extern struct NewWindow PanelWindowDEF;
  24. extern USHORT PanelColors[16];
  25. extern struct NewScreen GameScreenDEF;
  26. extern struct NewWindow GameWindowDEF;
  27. extern USHORT StdColors[16];
  28. extern USHORT GameColors[16];
  29. extern __chip USHORT mousedata[];
  30. extern struct Screen *gscreen;
  31. extern struct Screen *pscreen;
  32. extern struct Window *gwindow;
  33. extern struct Window *pwindow;
  34. extern struct RastPort *grp;
  35. extern struct RastPort *prp;
  36. extern struct ViewPort *gvp;
  37. extern struct ViewPort *pvp;
  38. extern UBYTE *gplane[4];
  39. extern UBYTE *pplane[4];
  40. extern APTR font2;
  41. extern CPTR MoveSound;
  42. extern CPTR ShuffleSound;
  43. extern CPTR NoShuffleSound;
  44. extern CPTR BonusSound;
  45. extern CPTR FallSound;
  46. extern CPTR DoorSound;
  47. extern CPTR End1Sound;
  48. extern CPTR End2Sound;
  49. extern BOOL music;
  50. extern BOOL sound;
  51. extern CPTR song;
  52.  
  53. extern char Buffer[];
  54.  
  55. /****************************/
  56. /* GAME DATA            */
  57. /****************************/
  58.  
  59. extern UBYTE Area[12][20];
  60.  
  61. extern SHORT Level;
  62. extern SHORT Bonus;
  63.  
  64. struct Player
  65.     {
  66.     SHORT XPos, YPos;
  67.     SHORT Score, Keys;
  68.     SHORT Count, Collect;
  69.     SHORT GamesWon, GamesPlayed;
  70.  
  71.     char *Name;
  72.     };
  73.  
  74. extern struct Player Player[];
  75. extern struct Player *p1, *p2;
  76.  
  77. /****************************/
  78. /* FUNCTION DECLARARTION    */
  79. /****************************/
  80.  
  81. SHORT Game();
  82. void EditLevel();
  83. void LoadGraphics();
  84. void LoadPanel();
  85. void LoadLevel();
  86. void LoadSounds();
  87. void OpenAll();
  88. void CloseAll(__A0 char *);
  89. void DoPlayer(__A0 struct Player *, __A1 struct Player *);
  90.  
  91. void PutArea(__D0 SHORT, __D1 SHORT);
  92. void PrintAt(__A0 struct RastPort *, __D0 SHORT, __D1 SHORT, __D2 SHORT, __D3 char *);
  93. void OPrintAt(__A0 struct RastPort *, __D0 SHORT, __D1 SHORT, __D2 SHORT, __D3 char *);
  94.  
  95. LONG InitPlayer();
  96. void RemMPlayer();
  97. void PlayModule(__A0 CPTR);
  98. void PlayModule2(__A0 CPTR);
  99. void StopPlayer();
  100. CPTR LoadModule(__A0 char *);
  101. void UnLoadModule(__A0 CPTR);
  102.  
  103. #include "Joystick.c"
  104.  
  105. /****************************/
  106. /* Game             */
  107. /****************************/
  108.  
  109. SHORT Game()
  110.     {
  111.     if ( !music )
  112.         RemMPlayer();
  113.  
  114.     /*************/
  115.     /* init game */
  116.     /*************/
  117.         {
  118.         SHORT x, y;
  119.         struct IntuiMessage *msg;
  120.  
  121.         while ( msg = (struct IntuiMessage *)GetMsg(pwindow->UserPort) )
  122.             ReplyMsg(msg);
  123.  
  124.         while ( msg = (struct IntuiMessage *)GetMsg(gwindow->UserPort) )
  125.             ReplyMsg(msg);
  126.  
  127.  
  128.         Bonus = 0;
  129.  
  130.         for ( x = 0 ; x < 20 ; x++ )
  131.             for ( y = 0 ; y < 12 ; y++ )
  132.             switch ( Area[y][x] )
  133.                 {
  134.                 case BONUS :
  135.                 case P1BONUS :
  136.                 case P2BONUS :
  137.                     Bonus++;
  138.                     break;
  139.                 }
  140.  
  141.         p1->XPos = 0;
  142.         p1->YPos = 0;
  143.         p1->Score = 0;
  144.         p1->Keys = 0;
  145.         p1->Count = rand() & 3;
  146.         p1->Collect = 0;
  147.  
  148.         p2->XPos = 19;
  149.         p2->YPos = 11;
  150.         p2->Score = 0;
  151.         p2->Keys = 0;
  152.         p2->Count = rand() & 3;
  153.         p2->Collect = 0;
  154.         }
  155.  
  156.     /*************/
  157.     /* draw area */
  158.     /*************/
  159.         {
  160.         SHORT x, y, i;
  161.  
  162.         LoadRGB4(gvp, GameColors, 16);
  163.  
  164.         for ( i = 0 ; i < 6 ; i++ )
  165.             {
  166.             for ( x = i ; x < 20-i ; x++ )
  167.                 {
  168.                 PutArea(i, x);
  169.                 PutArea(11-i, 19-x);
  170.                 Delay(1);
  171.                 }
  172.             for ( y = i ; y < 12-i ; y++ )
  173.                 {
  174.                 PutArea(y, 19-i);
  175.                 PutArea(11-y, i);
  176.                 Delay(1);
  177.                 }
  178.             }
  179.         }
  180.  
  181.     /************/
  182.     /* mainloop */
  183.     /************/
  184.  
  185.     while ( Bonus > 0 )
  186.         {
  187.         /*****************/
  188.         /* check for key */
  189.         /*****************/
  190.             {
  191.             struct IntuiMessage *msg;
  192.  
  193.             while ( msg = (struct IntuiMessage *)GetMsg(pwindow->UserPort) )
  194.                 {
  195.                 if ( (msg->Class == VANILLAKEY) && (msg->Code == ' ') )
  196.                     Bonus = 0;
  197.  
  198.                 ReplyMsg(msg);
  199.                 }
  200.  
  201.             while ( msg = (struct IntuiMessage *)GetMsg(gwindow->UserPort) )
  202.                 {
  203.                 if ( (msg->Class == VANILLAKEY) && (msg->Code == ' ') )
  204.                     Bonus = 0;
  205.  
  206.                 ReplyMsg(msg);
  207.                 }
  208.             }
  209.  
  210.         WaitTOF();
  211.  
  212.         DoPlayer(p1, p2);
  213.         DoPlayer(p2, p1);
  214.  
  215.         /************************/
  216.         /* print bonus & scores */
  217.         /************************/
  218.             {
  219.             sprintf(Buffer, "%06u", Bonus);
  220.             Move(prp, 136, 47);
  221.             Text(prp, Buffer, 6);
  222.  
  223.             sprintf(Buffer, "%04u", p1->Score);
  224.             Move(prp, 65, 15);
  225.             Text(prp, Buffer, 4);
  226.  
  227.             sprintf(Buffer, "%04u", p2->Score);
  228.             Move(prp, 280, 15);
  229.             Text(prp, Buffer, 4);
  230.             }
  231.         } /* mainloop */
  232.  
  233.     /****************/
  234.     /* clear screen */
  235.     /****************/
  236.         {
  237.         SHORT i;
  238.  
  239.         if ( sound )
  240.             {
  241.             PlaySound( End1Sound, MAXVOLUME, LEFT1, NORMALRATE, 1 );
  242.             Delay(5);
  243.             PlaySound( End1Sound, MAXVOLUME, RIGHT1, NORMALRATE, 1 );
  244.             }
  245.  
  246.         SetAPen(grp, 0);
  247.  
  248.         for ( i = 0 ; i < 320 ; i += 4 )
  249.             {
  250.             WaitTOF();
  251.             Move(grp, i, 0);     Draw(grp, i, 191);
  252.             Move(grp, 318-i, 0); Draw(grp, 318-i, 191);
  253.             }
  254.  
  255.         for ( i = 0 ; i < 192 ; i += 2 )
  256.             {
  257.             WaitTOF();
  258.             Move(grp, 0, i);     Draw(grp, 319, i);
  259.             Move(grp, 0, 191-i); Draw(grp, 319, 191-i);
  260.             }
  261.         }
  262.  
  263.     /*****************/
  264.     /* print message */
  265.     /*****************/
  266.  
  267.     SHORT ret;
  268.  
  269.     if ( sound )
  270.         {
  271.         PlaySound( End2Sound, MAXVOLUME, LEFT1, NORMALRATE, 1 );
  272.         Delay(5);
  273.         PlaySound( End2Sound, MAXVOLUME, RIGHT1, NORMALRATE, 1 );
  274.         }
  275.  
  276.     StdColors[0] = 0x000;
  277.     StdColors[1] = 0xFFF;
  278.     StdColors[2] = 0xAAA;
  279.     StdColors[3] = 0x888;
  280.     LoadRGB4(gvp, StdColors, 16);
  281.  
  282.     if ( p1->Score > p2->Score )
  283.         {
  284.         OPrintAt(grp, 160, 100, 0, "Player 1 wins");
  285.         p1->GamesWon++;
  286.         ret = -1;
  287.         }
  288.     else if ( p1->Score < p2->Score )
  289.         {
  290.         OPrintAt(grp, 160, 100, 0, "Player 2 wins");
  291.         p2->GamesWon++;
  292.         ret = 1;
  293.         }
  294.     else
  295.         {
  296.         if ( p1->Collect > p2->Collect )
  297.             {
  298.             OPrintAt(grp, 160, 100, 0, "Player 1 was faster");
  299.             p1->GamesWon++;
  300.             ret = -1;
  301.             }
  302.         else if ( p1->Collect < p2->Collect )
  303.             {
  304.             OPrintAt(grp, 160, 100, 0, "Player 2 was faster");
  305.             p2->GamesWon++;
  306.             ret = 1;
  307.             }
  308.         else
  309.             {
  310.             OPrintAt(grp, 160, 100, 0, "No player wins");
  311.             ret = 0;
  312.             }
  313.         }
  314.  
  315.     p1->GamesPlayed++;
  316.     p2->GamesPlayed++;
  317.  
  318.     while ( Joystick(PORT2) & 1 );
  319.     while ( !(Joystick(PORT2) & 1) );
  320.     while ( Joystick(PORT2) & 1 );
  321.  
  322.     if ( !music )
  323.         InitPlayer();
  324.  
  325.     return(ret);
  326.     }
  327.  
  328. /****************************/
  329. /* DoPlayer()               */
  330. /****************************/
  331.  
  332. void DoPlayer(__A0 struct Player *p, __A1 struct Player *e)
  333.     {
  334.     SHORT channel;
  335.     SHORT xpos = p->XPos, ypos = p->YPos;
  336.     BOOL change = 0;
  337.  
  338.     /* increase collectcount */
  339.  
  340.     p->Collect++;
  341.  
  342.  
  343.     /* check for delay */
  344.  
  345.     if ( p->Count-- > 0 )
  346.         return();
  347.  
  348.  
  349.     if ( p == p1 )
  350.         channel = LEFT1;
  351.     else
  352.         channel = RIGHT1;
  353.  
  354.     p->Count = 0;
  355.  
  356.     UBYTE joy;
  357.     if ( channel == LEFT1 )
  358.         joy = Joystick(PORT2);
  359.     else
  360.         joy = Joystick(PORT1);
  361.     joy &= 30;
  362.  
  363.     /**************/
  364.     /* move smily */
  365.     /**************/
  366.  
  367.     if ( (joy == RIGHT) && ( xpos < 19 ) )
  368.         {
  369.         xpos++;
  370.         change = RIGHT;
  371.         }
  372.     if ( (joy == LEFT) && ( xpos > 0 ) )
  373.         {
  374.         xpos--;
  375.         change = LEFT;
  376.         }
  377.     if ( (joy == DOWN) && ( ypos < 11 ) )
  378.         {
  379.         ypos++;
  380.         change = DOWN;
  381.         }
  382.     if ( (joy == UP) && ( ypos > 0 ) )
  383.         {
  384.         ypos--;
  385.         change = UP;
  386.         }
  387.  
  388.     /*****************/
  389.     /* check new pos */
  390.     /*****************/
  391.  
  392.     if ( change && ( (xpos != e->XPos) || (ypos != e->YPos) ) )
  393.         {
  394.         SHORT oldx = p->XPos, oldy = p->YPos;
  395.         switch ( Area[ypos][xpos] )
  396.             {
  397.             case P1BONUS :
  398.             case P2BONUS :
  399.                 if ( (Area[ypos][xpos] == P1BONUS) && (channel == LEFT1) )
  400.                 p->Score += 50;
  401.                 else if ( (Area[ypos][xpos] == P2BONUS) && (channel == RIGHT1) )
  402.                 p->Score += 50;
  403.             case BONUS :
  404.                 Bonus--;
  405.                 p->Score += 50;
  406.                 Area[ypos][xpos] = FLOOR;
  407.  
  408.                 p->XPos = xpos;
  409.                 p->YPos = ypos;
  410.  
  411.                 PutArea(oldy, oldx);
  412.                 PutArea(ypos, xpos);
  413.  
  414.                 p->Count = 10;
  415.                 p->Collect = 0;
  416.                 if ( sound )
  417.                 PlaySound( BonusSound, 32, channel, rand() & 127, 1 );
  418.                 break;
  419.             case KEY :
  420.                 p->Keys++;
  421.                 Area[ypos][xpos] = FLOOR;
  422.  
  423.                 p->XPos = xpos;
  424.                 p->YPos = ypos;
  425.  
  426.                 PutArea(oldy, oldx);
  427.                 PutArea(ypos, xpos);
  428.  
  429.                 p->Count = 10;
  430.                 if ( sound )
  431.                 PlaySound( BonusSound, 32, channel, rand() & 127, 1 );
  432.                 break;
  433.             case OPENEDDOOR :
  434.             case FLOOR :
  435.                 p->XPos = xpos;
  436.                 p->YPos = ypos;
  437.  
  438.                 PutArea(oldy, oldx);
  439.                 PutArea(ypos, xpos);
  440.  
  441.                 p->Count = 10;
  442.                 if ( sound )
  443.                 PlaySound( MoveSound, 32, channel, rand()&127, 1 );
  444.                 break;
  445.             case HOLE :
  446.                 p->XPos = -1;
  447.                 PutArea(oldy, oldx);
  448.                 if ( sound )
  449.                 PlaySound( FallSound, 32, channel, NORMALRATE, 1 );
  450.                 Delay(75);
  451.                 Bonus = 0;
  452.                 p->Score = 0;
  453.                 e->Score += 50;
  454.                 break;
  455.             case CLOSEDDOOR :
  456.                 if ( p->Keys > 0 )
  457.                 {
  458.                     p->Keys--;
  459.                     Area[ypos][xpos] = OPENEDDOOR;
  460.  
  461.                     p->XPos = xpos;
  462.                     p->YPos = ypos;
  463.  
  464.                     PutArea(oldy, oldx);
  465.                     PutArea(ypos, xpos);
  466.  
  467.                     p->Count = 20;
  468.                     if ( sound )
  469.                     PlaySound( DoorSound, 32, channel, NORMALRATE, 1 );
  470.                 }
  471.                 break;
  472.             case PINKWALL :
  473.             case PINKWALL2 :
  474.                 if ( sound )
  475.                 PlaySound(NoShuffleSound, 32, channel, rand()&127, 1 );
  476.                 p->Count = 10;
  477.                 break;
  478.             case GREYWALL :
  479.                 {
  480.                 SHORT i;
  481.                 BOOL ok = TRUE;
  482.                 SHORT pinkpos = -1;
  483.  
  484.                 switch ( change )
  485.                     {
  486.                     case RIGHT :
  487.                         /*****************/
  488.                         /* scan to right */
  489.                         /*****************/
  490.  
  491.                         for ( i = p->XPos + 1 ; (i != p->XPos) && ok ; i = (i + 1) % 20 )
  492.                         switch ( Area[ypos][i] )
  493.                             {
  494.                             case PINKWALL2 :
  495.                                 pinkpos = i;
  496.                             case PINKWALL :
  497.                             case OPENEDDOOR :
  498.                             case CLOSEDDOOR :
  499.                                 ok = FALSE;
  500.                                 break;
  501.                             }
  502.  
  503.                         /*******************/
  504.                         /* if pink occured */
  505.                         /*******************/
  506.  
  507.                         if ( !ok && (pinkpos == -1) )
  508.                         {
  509.                             if ( sound )
  510.                             PlaySound(NoShuffleSound, 32, channel, rand()&127, 1 );
  511.                             break;
  512.                         }
  513.  
  514.                         if ( pinkpos == -1 )
  515.                         {
  516.                             /*************/
  517.                             /* only grey */
  518.                             /*************/
  519.  
  520.                             p->XPos = xpos;
  521.                             p->YPos = ypos;
  522.  
  523.                             BYTE swap = Area[ypos][19];
  524.                             for ( i = 19 ; i > 0 ; i-- )
  525.                             Area[ypos][i] = Area[ypos][i-1];
  526.                             Area[ypos][0] = swap;
  527.  
  528.                             if ( e->YPos == ypos )
  529.                             {
  530.                                 e->XPos++;
  531.                                 if ( e->XPos > 19 )
  532.                                 e->XPos = 0;
  533.                             }
  534.  
  535.                             ScrollRaster(grp, -16, 0, 0, ypos*16, 319, ypos*16+15);
  536.                             PutArea(ypos, 0);
  537.  
  538.                             if ( sound )
  539.                             PlaySound(ShuffleSound, 32, channel, rand()&127, 1 );
  540.                         }
  541.                         else
  542.                         {
  543.                             /***************/
  544.                             /* found pink2 */
  545.                             /***************/
  546.  
  547.                             SHORT wall;
  548.  
  549.                             for (  wall = p->XPos+1 ; wall != pinkpos ; wall = (wall + 1) % 20 )
  550.                             if ( Area[ypos][wall] == FLOOR )
  551.                                 break;
  552.  
  553.                             /***************/
  554.                             /* if no floor */
  555.                             /***************/
  556.  
  557.                             if ( wall == pinkpos )
  558.                             {
  559.                                 if ( sound )
  560.                                 PlaySound(NoShuffleSound, 32, channel, rand()&127, 1 );
  561.                                 break;
  562.                             }
  563.  
  564.                             if ( wall > oldx )
  565.                             {
  566.                                 /***************/
  567.                                 /* no clipping */
  568.                                 /***************/
  569.  
  570.                                 /*******************/
  571.                                 /* if enemy blocks */
  572.                                 /*******************/
  573.  
  574.                                 if ( (e->YPos == ypos) && (e->XPos == wall) )
  575.                                 {
  576.                                     if ( sound )
  577.                                     PlaySound(NoShuffleSound, 32, channel, rand()&127, 1 );
  578.                                     break;
  579.                                 }
  580.  
  581.                                 p->XPos = xpos;
  582.                                 p->YPos = ypos;
  583.  
  584.                                 ScrollRaster(grp, -16, 0, oldx*16, ypos*16, wall*16+15, ypos*16+15);
  585.  
  586.                                 for ( i = wall-1 ; i > oldx ; i-- )
  587.                                 Area[ypos][i+1] = Area[ypos][i];
  588.  
  589.                                 Area[ypos][oldx+1] = FLOOR;
  590.                                 PutArea(ypos, oldx);
  591.  
  592.                                 if ( (e->YPos == ypos) && (e->XPos > oldx) && (e->XPos <= wall) )
  593.                                 {
  594.                                     e->XPos++;
  595.                                     if ( e->XPos > 19 )
  596.                                     e->XPos = 0;
  597.                                 }
  598.                             }
  599.                             else
  600.                             {
  601.                                 /*****************/
  602.                                 /* with clipping */
  603.                                 /*****************/
  604.  
  605.                                 /*******************/
  606.                                 /* if enemy blocks */
  607.                                 /*******************/
  608.  
  609.                                 if ( (e->YPos == ypos) && (e->XPos == wall) )
  610.                                 {
  611.                                     if ( sound )
  612.                                     PlaySound(NoShuffleSound, 32, channel, rand()&127, 1 );
  613.                                     break;
  614.                                 }
  615.  
  616.                                 p->XPos = xpos;
  617.                                 p->YPos = ypos;
  618.  
  619.                                 ScrollRaster(grp, -16, 0, oldx*16, ypos*16, 319, ypos*16+15);
  620.                                 ScrollRaster(grp, -16, 0, 0, ypos*16, wall*16+15, ypos*16+15);
  621.  
  622.                                 BYTE swap = Area[ypos][19];
  623.                                 for ( i = 18 ; i > oldx ; i-- )
  624.                                 Area[ypos][i+1] = Area[ypos][i];
  625.  
  626.                                 for ( i = wall-1 ; i >= 0 ; i-- )
  627.                                 Area[ypos][i+1] = Area[ypos][i];
  628.                                 Area[ypos][0] = swap;
  629.                                 PutArea(ypos, 0);
  630.  
  631.                                 Area[ypos][oldx+1] = FLOOR;
  632.                                 PutArea(ypos, oldx);
  633.  
  634.                                 if ( (e->YPos == ypos) && ( (e->XPos > oldx) || (e->XPos <= wall) ) )
  635.                                 {
  636.                                     e->XPos++;
  637.                                     if ( e->XPos > 19 )
  638.                                     e->XPos = 0;
  639.                                 }
  640.                             }
  641.                         }
  642.                         break;
  643.  
  644.                     case LEFT :
  645.                         for ( i = p->XPos - 1 ; (i != p->XPos) && ok ; i = (i + 19) % 20 )
  646.                         switch ( Area[ypos][i] )
  647.                             {
  648.                             case PINKWALL2 :
  649.                                 pinkpos = i;
  650.                             case PINKWALL :
  651.                             case OPENEDDOOR :
  652.                             case CLOSEDDOOR :
  653.                                 ok = FALSE;
  654.                                 break;
  655.                             }
  656.  
  657.                         /*******************/
  658.                         /* if pink occured */
  659.                         /*******************/
  660.  
  661.                         if ( !ok && (pinkpos == -1) )
  662.                         {
  663.                             if ( sound )
  664.                             PlaySound(NoShuffleSound, 32, channel, rand()&127, 1 );
  665.                             break;
  666.                         }
  667.  
  668.                         if ( pinkpos == -1 )
  669.                         {
  670.                             p->XPos = xpos;
  671.                             p->YPos = ypos;
  672.  
  673.                             BYTE swap = Area[ypos][0];
  674.                             for ( i = 0 ; i < 19 ; i++ )
  675.                             Area[ypos][i] = Area[ypos][i+1];
  676.                             Area[ypos][19] = swap;
  677.  
  678.                             if ( e->YPos == ypos )
  679.                             {
  680.                                 e->XPos--;
  681.                                 if ( e->XPos < 0 )
  682.                                 e->XPos = 19;
  683.                             }
  684.  
  685.                             ScrollRaster(grp, 16, 0, 0, ypos*16, 319, ypos*16+15);
  686.                             PutArea(ypos, 19);
  687.  
  688.                             if ( sound )
  689.                             PlaySound(ShuffleSound, 32, channel, rand()&127, 1 );
  690.                         }
  691.                         else
  692.                         {
  693.                             /***************/
  694.                             /* pink2 found */
  695.                             /***************/
  696.  
  697.                             SHORT wall;
  698.  
  699.                             for (  wall = p->XPos-1 ; wall != pinkpos ; wall = (wall + 19) % 20 )
  700.                             if ( Area[ypos][wall] == FLOOR )
  701.                                 break;
  702.  
  703.                             /***************/
  704.                             /* if no floor */
  705.                             /***************/
  706.  
  707.                             if ( wall == pinkpos )
  708.                             {
  709.                                 if ( sound )
  710.                                 PlaySound(NoShuffleSound, 32, channel, rand()&127, 1 );
  711.                                 break;
  712.                             }
  713.  
  714.                             if ( wall < oldx )
  715.                             {
  716.                                 /***************/
  717.                                 /* no clipping */
  718.                                 /***************/
  719.  
  720.                                 /*******************/
  721.                                 /* if enemy blocks */
  722.                                 /*******************/
  723.  
  724.                                 if ( (e->YPos == ypos) && (e->XPos == wall) )
  725.                                 {
  726.                                     if ( sound )
  727.                                     PlaySound(NoShuffleSound, 32, channel, rand()&127, 1 );
  728.                                     break;
  729.                                 }
  730.  
  731.                                 p->XPos = xpos;
  732.                                 p->YPos = ypos;
  733.  
  734.                                 ScrollRaster(grp, 16, 0, wall*16, ypos*16, oldx*16+15, ypos*16+15);
  735.  
  736.                                 for ( i = wall+1 ; i < oldx ; i++ )
  737.                                 Area[ypos][i-1] = Area[ypos][i];
  738.  
  739.                                 Area[ypos][oldx-1] = FLOOR;
  740.                                 PutArea(ypos, oldx);
  741.  
  742.                                 if ( (e->YPos == ypos) && (e->XPos < oldx) && (e->XPos >= wall) )
  743.                                 {
  744.                                     e->XPos--;
  745.                                     if ( e->XPos < 0 )
  746.                                     e->XPos = 19;
  747.                                 }
  748.                             }
  749.                             else
  750.                             {
  751.                                 /*****************/
  752.                                 /* with clipping */
  753.                                 /*****************/
  754.  
  755.                                 /*******************/
  756.                                 /* if enemy blocks */
  757.                                 /*******************/
  758.  
  759.                                 if ( (e->YPos == ypos) && (e->XPos == wall) )
  760.                                 {
  761.                                     if ( sound )
  762.                                     PlaySound(NoShuffleSound, 32, channel, rand()&127, 1 );
  763.                                     break;
  764.                                 }
  765.  
  766.                                 p->XPos = xpos;
  767.                                 p->YPos = ypos;
  768.  
  769.                                 ScrollRaster(grp, 16, 0, 0, ypos*16, oldx*16+15, ypos*16+15);
  770.                                 ScrollRaster(grp, 16, 0, wall*16, ypos*16, 319, ypos*16+15);
  771.  
  772.                                 BYTE swap = Area[ypos][0];
  773.                                 for ( i = 1 ; i < oldx ; i++ )
  774.                                 Area[ypos][i-1] = Area[ypos][i];
  775.  
  776.                                 for ( i = wall+1 ; i <= 19 ; i++ )
  777.                                 Area[ypos][i-1] = Area[ypos][i];
  778.                                 Area[ypos][19] = swap;
  779.                                 PutArea(ypos, 19);
  780.  
  781.                                 Area[ypos][oldx-1] = FLOOR;
  782.                                 PutArea(ypos, oldx);
  783.  
  784.                                 if ( (e->YPos == ypos) && ( (e->XPos < oldx) || (e->XPos >= wall) ) )
  785.                                 {
  786.                                     e->XPos--;
  787.                                     if ( e->XPos < 0 )
  788.                                     e->XPos = 19;
  789.                                 }
  790.                             }
  791.                         }
  792.                         break;
  793.  
  794.                     case DOWN :
  795.                         /*************/
  796.                         /* scan down */
  797.                         /*************/
  798.  
  799.                         for ( i = p->YPos + 1 ; (i != p->YPos) && ok ; i = (i + 1) % 12 )
  800.                         switch ( Area[i][xpos] )
  801.                             {
  802.                             case PINKWALL2 :
  803.                                 pinkpos = i;
  804.                             case PINKWALL :
  805.                             case OPENEDDOOR :
  806.                             case CLOSEDDOOR :
  807.                                 ok = FALSE;
  808.                                 break;
  809.                             }
  810.  
  811.                         /*******************/
  812.                         /* if pink occured */
  813.                         /*******************/
  814.  
  815.                         if ( !ok && (pinkpos == -1) )
  816.                         {
  817.                             if ( sound )
  818.                             PlaySound(NoShuffleSound, 32, channel, rand()&127, 1 );
  819.                             break;
  820.                         }
  821.  
  822.                         if ( pinkpos == -1 )
  823.                         {
  824.                             /*************/
  825.                             /* only grey */
  826.                             /*************/
  827.  
  828.                             p->XPos = xpos;
  829.                             p->YPos = ypos;
  830.  
  831.                             BYTE swap = Area[11][xpos];
  832.                             for ( i = 11 ; i > 0 ; i-- )
  833.                             Area[i][xpos] = Area[i-1][xpos];
  834.                             Area[0][xpos] = swap;
  835.  
  836.                             if ( e->XPos == xpos )
  837.                             {
  838.                                 e->YPos++;
  839.                                 if ( e->YPos > 11 )
  840.                                 e->YPos = 0;
  841.                             }
  842.  
  843.                             ScrollRaster(grp, 0, -16, xpos*16, 0, xpos*16+15, 191);
  844.                             PutArea(0, xpos);
  845.  
  846.                             if ( sound )
  847.                             PlaySound(ShuffleSound, 32, channel, rand()&127, 1 );
  848.                         }
  849.                         else
  850.                         {
  851.                             /***************/
  852.                             /* found pink2 */
  853.                             /***************/
  854.  
  855.                             SHORT wall;
  856.  
  857.                             for (  wall = p->YPos+1 ; wall != pinkpos ; wall = (wall + 1) % 12 )
  858.                             if ( Area[wall][xpos] == FLOOR )
  859.                                 break;
  860.  
  861.                             /***************/
  862.                             /* if no floor */
  863.                             /***************/
  864.  
  865.                             if ( wall == pinkpos )
  866.                             {
  867.                                 if ( sound )
  868.                                 PlaySound(NoShuffleSound, 32, channel, rand()&127, 1 );
  869.                                 break;
  870.                             }
  871.  
  872.                             if ( wall > oldy )
  873.                             {
  874.                                 /***************/
  875.                                 /* no clipping */
  876.                                 /***************/
  877.  
  878.                                 /*******************/
  879.                                 /* if enemy blocks */
  880.                                 /*******************/
  881.  
  882.                                 if ( (e->XPos == xpos) && (e->YPos == wall) )
  883.                                 {
  884.                                     if ( sound )
  885.                                     PlaySound(NoShuffleSound, 32, channel, rand()&127, 1 );
  886.                                     break;
  887.                                 }
  888.  
  889.                                 p->XPos = xpos;
  890.                                 p->YPos = ypos;
  891.  
  892.                                 ScrollRaster(grp, 0, -16, xpos*16, oldy*16, xpos*16+15, wall*16+15);
  893.  
  894.                                 for ( i = wall-1 ; i > oldy ; i-- )
  895.                                 Area[i+1][xpos] = Area[i][xpos];
  896.  
  897.                                 Area[oldy+1][xpos] = FLOOR;
  898.                                 PutArea(oldy, xpos);
  899.  
  900.                                 if ( (e->XPos == xpos) && (e->YPos > oldy) && (e->YPos <= wall) )
  901.                                 {
  902.                                     e->YPos++;
  903.                                     if ( e->YPos > 11 )
  904.                                     e->YPos = 0;
  905.                                 }
  906.                             }
  907.                             else
  908.                             {
  909.                                 /*****************/
  910.                                 /* with clipping */
  911.                                 /*****************/
  912.  
  913.                                 /*******************/
  914.                                 /* if enemy blocks */
  915.                                 /*******************/
  916.  
  917.                                 if ( (e->XPos == xpos) && (e->YPos == wall) )
  918.                                 {
  919.                                     if ( sound )
  920.                                     PlaySound(NoShuffleSound, 32, channel, rand()&127, 1 );
  921.                                     break;
  922.                                 }
  923.  
  924.                                 p->XPos = xpos;
  925.                                 p->YPos = ypos;
  926.  
  927.                                 ScrollRaster(grp, 0, -16, xpos*16, oldy*16, xpos*16+15, 191);
  928.                                 ScrollRaster(grp, 0, -16, xpos*16, 0, xpos*16+15, wall*16+15);
  929.  
  930.                                 BYTE swap = Area[11][xpos];
  931.                                 for ( i = 10 ; i > oldy ; i-- )
  932.                                 Area[i+1][xpos] = Area[i][xpos];
  933.  
  934.                                 for ( i = wall-1 ; i >= 0 ; i-- )
  935.                                 Area[i+1][xpos] = Area[i][xpos];
  936.                                 Area[0][xpos] = swap;
  937.                                 PutArea(0, xpos);
  938.  
  939.                                 Area[oldy+1][xpos] = FLOOR;
  940.                                 PutArea(oldy, xpos);
  941.  
  942.                                 if ( (e->XPos == xpos) && ( (e->YPos > oldy) || (e->YPos <= wall) ) )
  943.                                 {
  944.                                     e->YPos++;
  945.                                     if ( e->YPos > 11 )
  946.                                     e->YPos = 0;
  947.                                 }
  948.                             }
  949.                         }
  950.                         break;
  951.  
  952.                     case UP :
  953.                         for ( i = p->YPos - 1 ; (i != p->YPos) && ok ; i = (i + 11) % 12 )
  954.                         switch ( Area[i][xpos] )
  955.                             {
  956.                             case PINKWALL2 :
  957.                                 pinkpos = i;
  958.                             case PINKWALL :
  959.                             case OPENEDDOOR :
  960.                             case CLOSEDDOOR :
  961.                                 ok = FALSE;
  962.                                 break;
  963.                             }
  964.  
  965.                         /*******************/
  966.                         /* if pink occured */
  967.                         /*******************/
  968.  
  969.                         if ( !ok && (pinkpos == -1) )
  970.                         {
  971.                             if ( sound )
  972.                             PlaySound(NoShuffleSound, 32, channel, rand()&127, 1 );
  973.                             break;
  974.                         }
  975.  
  976.                         if ( pinkpos == -1 )
  977.                         {
  978.                             p->XPos = xpos;
  979.                             p->YPos = ypos;
  980.  
  981.                             BYTE swap = Area[0][xpos];
  982.                             for ( i = 0 ; i < 11 ; i++ )
  983.                             Area[i][xpos] = Area[i+1][xpos];
  984.                             Area[11][xpos] = swap;
  985.  
  986.                             if ( e->XPos == xpos )
  987.                             {
  988.                                 e->YPos--;
  989.                                 if ( e->YPos < 0 )
  990.                                 e->YPos = 11;
  991.                             }
  992.  
  993.                             ScrollRaster(grp, 0, 16, xpos*16, 0, xpos*16+15, 191);
  994.                             PutArea(11, xpos);
  995.  
  996.                             if ( sound )
  997.                             PlaySound(ShuffleSound, 32, channel, rand()&127, 1 );
  998.                         }
  999.                         else
  1000.                         {
  1001.                             SHORT wall;
  1002.  
  1003.                             for (  wall = p->YPos-1 ; wall != pinkpos ; wall = (wall + 11) % 12 )
  1004.                             if ( Area[wall][xpos] == FLOOR )
  1005.                                 break;
  1006.  
  1007.                             /***************/
  1008.                             /* if no floor */
  1009.                             /***************/
  1010.  
  1011.                             if ( wall == pinkpos )
  1012.                             {
  1013.                                 if ( sound )
  1014.                                 PlaySound(NoShuffleSound, 32, channel, rand()&127, 1 );
  1015.                                 break;
  1016.                             }
  1017.  
  1018.                             if ( wall < oldy )
  1019.                             {
  1020.                                 /***************/
  1021.                                 /* no clipping */
  1022.                                 /***************/
  1023.  
  1024.                                 /*******************/
  1025.                                 /* if enemy blocks */
  1026.                                 /*******************/
  1027.  
  1028.                                 if ( (e->XPos == xpos) && (e->YPos == wall) )
  1029.                                 {
  1030.                                     if ( sound )
  1031.                                     PlaySound(NoShuffleSound, 32, channel, rand()&127, 1 );
  1032.                                     break;
  1033.                                 }
  1034.  
  1035.                                 p->XPos = xpos;
  1036.                                 p->YPos = ypos;
  1037.  
  1038.                                 ScrollRaster(grp, 0, 16, xpos*16, wall*16, xpos*16+15, oldy*16+15);
  1039.  
  1040.                                 for ( i = wall+1 ; i < oldy ; i++ )
  1041.                                 Area[i-1][xpos] = Area[i][xpos];
  1042.  
  1043.                                 Area[oldy-1][xpos] = FLOOR;
  1044.                                 PutArea(oldy, xpos);
  1045.  
  1046.                                 if ( (e->XPos == xpos) && (e->YPos < oldy) && (e->YPos >= wall) )
  1047.                                 {
  1048.                                     e->YPos--;
  1049.                                     if ( e->YPos < 0 )
  1050.                                     e->YPos = 11;
  1051.                                 }
  1052.                             }
  1053.                             else
  1054.                             {
  1055.                                 /*****************/
  1056.                                 /* with clipping */
  1057.                                 /*****************/
  1058.  
  1059.                                 /*******************/
  1060.                                 /* if enemy blocks */
  1061.                                 /*******************/
  1062.  
  1063.                                 if ( (e->XPos == xpos) && (e->YPos == wall) )
  1064.                                 {
  1065.                                     if ( sound )
  1066.                                     PlaySound(NoShuffleSound, 32, channel, rand()&127, 1 );
  1067.                                     break;
  1068.                                 }
  1069.  
  1070.                                 p->XPos = xpos;
  1071.                                 p->YPos = ypos;
  1072.  
  1073.                                 ScrollRaster(grp, 0, 16, xpos*16, 0, xpos*16+15, oldy*16+15);
  1074.                                 ScrollRaster(grp, 0, 16, xpos*16, wall*16, xpos*16+15, 191);
  1075.  
  1076.                                 BYTE swap = Area[0][xpos];
  1077.                                 for ( i = 1 ; i < oldy ; i++ )
  1078.                                 Area[i-1][xpos] = Area[i][xpos];
  1079.  
  1080.                                 for ( i = wall+1 ; i <= 11 ; i++ )
  1081.                                 Area[i-1][xpos] = Area[i][xpos];
  1082.                                 Area[11][xpos] = swap;
  1083.                                 PutArea(11, xpos);
  1084.  
  1085.                                 Area[oldy-1][xpos] = FLOOR;
  1086.                                 PutArea(oldy, xpos);
  1087.  
  1088.                                 if ( (e->XPos == xpos) && ( (e->YPos < oldy) || (e->YPos >= wall) ) )
  1089.                                 {
  1090.                                     e->YPos--;
  1091.                                     if ( e->YPos < 0 )
  1092.                                     e->YPos = 11;
  1093.                                 }
  1094.                             }
  1095.                         }
  1096.                         break;
  1097.                     } /* switch */
  1098.  
  1099.                 PutArea(e->YPos, e->XPos);
  1100.  
  1101.                 p->Count = 15;
  1102.                 } /* case GREYWALL */
  1103.             break;
  1104.             } /* switch (Area.. */
  1105.         } /* if ( change.. */
  1106.     } /* do player 1 */
  1107.  
  1108. /****************************/
  1109. /* PutArea            */
  1110. /****************************/
  1111.  
  1112. void PutArea(__D0 SHORT y, __D1 SHORT x)
  1113.     {
  1114.     if ( (p1->XPos == x) && (p1->YPos == y) )
  1115.         {
  1116.         ClipBlit(grp, 96, 192, grp, x*16, y*16, 16, 16, 0xC0);
  1117.         }
  1118.     else if ( (p2->XPos == x) && (p2->YPos == y) )
  1119.         {
  1120.         ClipBlit(grp, 96, 208, grp, x*16, y*16, 16, 16, 0xC0);
  1121.         }
  1122.     else
  1123.         {
  1124.         switch ( Area[y][x] )
  1125.             {
  1126.             case FLOOR :
  1127.                 ClipBlit(grp, 0, 192, grp, x*16, y*16, 16, 16, 0xC0);
  1128.                 break;
  1129.             case GREYWALL :
  1130.                 ClipBlit(grp, 16, 192, grp, x*16, y*16, 16, 16, 0xC0);
  1131.                 break;
  1132.             case PINKWALL :
  1133.                 ClipBlit(grp, 32, 192, grp, x*16, y*16, 16, 16, 0xC0);
  1134.                 break;
  1135.             case PINKWALL2 :
  1136.                 ClipBlit(grp, 48, 192, grp, x*16, y*16, 16, 16, 0xC0);
  1137.                 break;
  1138.             case CLOSEDDOOR :
  1139.                 ClipBlit(grp, 64, 192, grp, x*16, y*16, 16, 16, 0xC0);
  1140.                 break;
  1141.             case OPENEDDOOR :
  1142.                 ClipBlit(grp, 80, 192, grp, x*16, y*16, 16, 16, 0xC0);
  1143.                 break;
  1144.             case HOLE :
  1145.                 ClipBlit(grp, 0, 208, grp, x*16, y*16, 16, 16, 0xC0);
  1146.                 break;
  1147.             case KEY :
  1148.                 ClipBlit(grp, 16, 208, grp, x*16, y*16, 16, 16, 0xC0);
  1149.                 break;
  1150.             case P1BONUS :
  1151.                 ClipBlit(grp, 48, 208, grp, x*16, y*16, 16, 16, 0xC0);
  1152.                 break;
  1153.             case P2BONUS :
  1154.                 ClipBlit(grp, 32, 208, grp, x*16, y*16, 16, 16, 0xC0);
  1155.                 break;
  1156.             case BONUS :
  1157.                 ClipBlit(grp, 64, 208, grp, x*16, y*16, 16, 16, 0xC0);
  1158.                 break;
  1159.             }
  1160.         }
  1161.     }
  1162.  
  1163. /****************************/
  1164. /* LoadPanel            */
  1165. /****************************/
  1166.  
  1167. void LoadPanel()
  1168.     {
  1169.     SHORT i;
  1170.     BPTR file;
  1171.  
  1172.     for ( i = 0 ; i < 16 ; i++ )
  1173.         SetRGB4(pvp, i, 0, 0, 0);
  1174.  
  1175.     file = (BPTR)Open("Panel.data", MODE_OLDFILE);
  1176.     if ( !file )
  1177.         CloseAll("No panel.");
  1178.  
  1179.     for ( i = 0 ; i < 4 ; i++ )
  1180.         {
  1181.         Read(file, prp->BitMap->Planes[i], 2240);
  1182.         }
  1183.  
  1184.     Read(file, PanelColors, 32);
  1185.  
  1186.     Close(file);
  1187.     LoadRGB4(pvp, PanelColors, 16);
  1188.     }
  1189.  
  1190. /****************************/
  1191. /* LoadLevel            */
  1192. /****************************/
  1193.  
  1194. void LoadLevel()
  1195.     {
  1196.     struct FileHandle *file;
  1197.  
  1198.     if ( file = (struct FileHandle *)Open("Levels.data", MODE_OLDFILE) )
  1199.         {
  1200.         LONG index = (Level-1) * 240;
  1201.  
  1202.         Seek(file, index, OFFSET_BEGINNING);
  1203.  
  1204.         Read(file, Area, 240);
  1205.  
  1206.         Close(file);
  1207.         }
  1208.     else
  1209.         {
  1210.         DisplayBeep(NULL);
  1211.         }
  1212.     }
  1213.  
  1214. /****************************/
  1215. /* LoadGraphics         */
  1216. /****************************/
  1217.  
  1218. void LoadGraphics()
  1219.     {
  1220.     SHORT i;
  1221.     struct FileHandle *file;
  1222.  
  1223.     file = (struct FileHandle *)Open("Graphics.data", MODE_OLDFILE);
  1224.     if ( !file )
  1225.         CloseAll("No Graphics.data.");
  1226.  
  1227.     for ( i = 0 ; i < 4 ; i++ )
  1228.         {
  1229.         Read(file, gplane[i]+192*40, 32*40);
  1230.         }
  1231.  
  1232.     Read(file, GameColors, 32);
  1233.  
  1234.     Close(file);
  1235.     }
  1236.  
  1237. /****************************/
  1238. /* LoadSounds            */
  1239. /****************************/
  1240.  
  1241. void LoadSounds()
  1242.     {
  1243.     MoveSound = PrepareSound("Move.snd");
  1244.     if ( !MoveSound )
  1245.         CloseAll("No Move.snd");
  1246.  
  1247.     ShuffleSound = PrepareSound("Shuffle.snd");
  1248.     if ( !ShuffleSound )
  1249.         CloseAll("No Shuffle.snd");
  1250.  
  1251.     NoShuffleSound = PrepareSound("NoShuffle.snd");
  1252.     if ( !NoShuffleSound )
  1253.         CloseAll("No NoShuffle.snd");
  1254.  
  1255.     BonusSound = PrepareSound("Bonus.snd");
  1256.     if ( !BonusSound )
  1257.         CloseAll("No Bonus.snd");
  1258.  
  1259.     FallSound = PrepareSound("Fall.snd");
  1260.     if ( !FallSound )
  1261.         CloseAll("No Fall.snd");
  1262.  
  1263.     DoorSound = PrepareSound("Door.snd");
  1264.     if ( !DoorSound )
  1265.         CloseAll("No Door.snd");
  1266.  
  1267.     End1Sound = PrepareSound("End1.snd");
  1268.     if ( !End1Sound )
  1269.         CloseAll("No End1.snd");
  1270.  
  1271.     End2Sound = PrepareSound("End2.snd");
  1272.     if ( !End2Sound )
  1273.         CloseAll("No End2.snd");
  1274.  
  1275.     song = LoadModule("Underground.song");
  1276.     if ( !song )
  1277.         music = FALSE;
  1278.     else
  1279.         {
  1280.         music = TRUE;
  1281.         InitPlayer();
  1282.         PlayModule(song);
  1283.         }
  1284.     }
  1285.  
  1286. /****************************/
  1287. /* OpenAll            */
  1288. /****************************/
  1289.  
  1290. void OpenAll()
  1291.     {
  1292.     SHORT i;
  1293.  
  1294.     /* open font */
  1295.  
  1296.     if ( !( font2 = (APTR)OpenDiskFont(&Font2DEF) ) )
  1297.         CloseAll("No font2 !!");
  1298.  
  1299.  
  1300.     /* open game screen */
  1301.  
  1302.     if ( !( gscreen = (struct Screen *)OpenScreen(&GameScreenDEF) ) )
  1303.         CloseAll("No game screen !!");
  1304.  
  1305.     GameWindowDEF.Screen = gscreen;
  1306.  
  1307.     if ( !( gwindow = (struct Window *)OpenWindow(&GameWindowDEF) ) )
  1308.         CloseAll("No game window !!");
  1309.  
  1310.     grp = &gscreen->RastPort;
  1311.     gvp = &gscreen->ViewPort;
  1312.  
  1313.     for ( i = 0 ; i < 5 ; i++ )
  1314.         gplane[i] = grp->BitMap->Planes[i];
  1315.  
  1316.     SetPointer(gwindow, mousedata, 0, 0, 0, 0);
  1317.     SetDrMd(grp, JAM1);
  1318.  
  1319.     /* open panel screen */
  1320.  
  1321.     if ( !( pscreen = (struct Screen *)OpenScreen(&PanelScreenDEF) ) )
  1322.         CloseAll("No panel screen !!");
  1323.  
  1324.     PanelWindowDEF.Screen = pscreen;
  1325.  
  1326.     if ( !( pwindow = (struct Window *)OpenWindow(&PanelWindowDEF) ) )
  1327.         CloseAll("No panel window !!");
  1328.  
  1329.     prp = &pscreen->RastPort;
  1330.     pvp = &pscreen->ViewPort;
  1331.  
  1332.     for ( i = 0 ; i < 4 ; i++ )
  1333.         pplane[i] = prp->BitMap->Planes[i];
  1334.  
  1335.     SetPointer(pwindow, mousedata, 0, 0, 0, 0);
  1336.     SetAPen(prp, 4);
  1337.     SetBPen(prp, 5);
  1338.     }
  1339.  
  1340. /****************************/
  1341. /* CloseAll            */
  1342. /****************************/
  1343.  
  1344. void CloseAll(__A0 char *text)
  1345.     {
  1346.     puts(text);
  1347.  
  1348.     StopPlayer();
  1349.     RemMPlayer();
  1350.  
  1351.     StopSound(LEFT0);
  1352.     StopSound(LEFT1);
  1353.     StopSound(RIGHT0);
  1354.     StopSound(RIGHT1);
  1355.  
  1356.     RemoveSound(MoveSound);
  1357.     RemoveSound(ShuffleSound);
  1358.     RemoveSound(NoShuffleSound);
  1359.     RemoveSound(BonusSound);
  1360.     RemoveSound(FallSound);
  1361.     RemoveSound(DoorSound);
  1362.     RemoveSound(End1Sound);
  1363.     RemoveSound(End2Sound);
  1364.  
  1365.     if (song) UnLoadModule(song);
  1366.     if (gwindow) CloseWindow(gwindow);
  1367.     if (gscreen) CloseScreen(gscreen);
  1368.     if (pwindow) CloseWindow(pwindow);
  1369.     if (pscreen) CloseScreen(pscreen);
  1370.     if (font2) CloseFont(font2);
  1371.  
  1372.     exit(0);
  1373.     }
  1374.  
  1375. /****************************/
  1376. /* PrintAt            */
  1377. /****************************/
  1378.  
  1379. void PrintAt(__A0 struct RastPort *rp, __D0 SHORT x, __D1 SHORT y, __D2 SHORT m, __D3 char *t)
  1380.     {
  1381.     SHORT l = strlen(t);
  1382.  
  1383.     switch (m)
  1384.         {
  1385.         case -1 :
  1386.             Move(rp, x, y);
  1387.             break;
  1388.         case 0 :
  1389.             Move(rp, x - TextLength(rp, t, l)/2, y);
  1390.             break;
  1391.         case 1 :
  1392.             Move(rp, x - TextLength(rp, t, l), y);
  1393.             break;
  1394.         }
  1395.  
  1396.     Text(rp, t, l);
  1397.     }
  1398.  
  1399. /****************************/
  1400. /* OPrintAt            */
  1401. /****************************/
  1402.  
  1403. void OPrintAt(__A0 struct RastPort *rp, __D0 SHORT x, __D1 SHORT y, __D2 SHORT m, __D3 char *t)
  1404.     {
  1405.     SHORT l = strlen(t);
  1406.  
  1407.     switch (m)
  1408.         {
  1409.         case 0 :
  1410.             x = x - TextLength(rp, t, l)/2;
  1411.             break;
  1412.         case 1 :
  1413.             x = x - TextLength(rp, t, l);
  1414.             break;
  1415.         }
  1416.  
  1417.     SetAPen(rp, 3);
  1418.     Move(rp, x+1, y); Text(rp, t, l);
  1419.     Move(rp, x, y+1); Text(rp, t, l);
  1420.     SetAPen(rp, 2);
  1421.     Move(rp, x-1, y); Text(rp, t, l);
  1422.     Move(rp, x, y-1); Text(rp, t, l);
  1423.     SetAPen(rp, 1);
  1424.     Move(rp, x, y); Text(rp, t, l);
  1425.     }
  1426.  
  1427.  
  1428.